using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace InduMall.Core.Models.Mapping
{
    public class RecommendProductMap : EntityTypeConfiguration<RecommendProduct>
    {
        public RecommendProductMap()
        {
            // Primary Key
            this.HasKey(t => t.RecommendProductId);

            // Properties
            this.Property(t => t.RecommendProductId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("RecommendProduct");
            this.Property(t => t.RecommendProductId).HasColumnName("RecommendProductId");
            this.Property(t => t.ProductId).HasColumnName("ProductId");
            this.Property(t => t.PublishedDate).HasColumnName("PublishedDate");
            this.Property(t => t.ExpireationDate).HasColumnName("ExpireationDate");
            this.Property(t => t.Rank).HasColumnName("Rank");

            // Relationships
            this.HasRequired(t => t.Product)
                .WithMany(t => t.RecommendProducts)
                .HasForeignKey(d => d.ProductId);

        }
    }
}
